//
//  LoginViewController.m
//  UI_元旦豆瓣
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "LoginViewController.h"
#import "RegisteredViewController.h"
@interface LoginViewController ()

@end

@implementation LoginViewController

- (void)dealloc{
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"用户登录";
    self.navigationController.navigationBar.backgroundColor = [UIColor whiteColor];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(buttonAction)];
    self.navigationItem.leftBarButtonItem = item;
    [item release];
    
    UILabel *nameLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 70, 40)];
    nameLable.backgroundColor = [UIColor clearColor];
    [self.view addSubview:nameLable];
    nameLable.font = [UIFont systemFontOfSize:20];
    nameLable.text = @"用户名:";
    
    UITextField *nameText = [[UITextField alloc] initWithFrame:CGRectMake(150, 100, 200, 40)];
    nameText.backgroundColor = [UIColor clearColor];
    nameText.placeholder = @"请输入用户名";
    [self.view addSubview:nameText];
    nameText.layer.cornerRadius = 10;
    nameText.layer.borderWidth = 1;
    [nameText release];
    
    UILabel *mmLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 170, 70, 40)];
    mmLable.backgroundColor = [UIColor clearColor];
    [self.view addSubview:mmLable];
    mmLable.font = [UIFont systemFontOfSize:20];
    mmLable.text = @"密码:";
    
    UITextField *mmText = [[UITextField alloc] initWithFrame:CGRectMake(150, 170, 200, 40)];
    mmText.backgroundColor = [UIColor clearColor];
    mmText.placeholder = @"请输入密码";
    [self.view addSubview:mmText];
    mmText.layer.cornerRadius = 10;
    mmText.layer.borderWidth = 1;
    [mmText release];

    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.backgroundColor = [UIColor greenColor];
    [button1 setTitle:@"登录" forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    button1.layer.cornerRadius = 10;
    button1.frame = CGRectMake(50, 250, 130, 50);
    [button1 addTarget:self action:@selector(buttonAction1) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.backgroundColor = [UIColor orangeColor];
    [button2 setTitle:@"注册" forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    button2.layer.cornerRadius = 10;
    button2.frame = CGRectMake(220, 250, 130, 50);
    [button2 addTarget:self action:@selector(buttonAction2) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button2];
    
    
    
}

- (void)buttonAction1{
//    [self.navigationController popToViewController:self.navigationController.viewControllers[0] animated:YES];
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (void)buttonAction2{
    RegisteredViewController *reg = [[RegisteredViewController alloc] init];
    [self.navigationController pushViewController:reg animated:YES];

}

- (void)buttonAction{
    
//    [self.navigationController popToViewController:self.navigationController.viewControllers[0] animated:YES];
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
